package com.qs.user.ui.VM;

import android.databinding.BindingAdapter;
import android.databinding.ObservableField;
import android.support.annotation.NonNull;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.qs.user.R;

import me.goldze.mvvmhabit.base.ItemViewModel;

/**
 * 识别历史图片item
 *
 * @Author ltzz
 * @Date 2019/8/24
 */
public class IdentifyHistoricalImgItemViewModel extends ItemViewModel<IdentifyHistoricalViewModel> {
    public ObservableField<String> mItemEntity = new ObservableField<>();

    public IdentifyHistoricalImgItemViewModel(@NonNull IdentifyHistoricalViewModel viewModel, String itemEntity) {
        super(viewModel);
        mItemEntity.set(itemEntity);
    }


    @BindingAdapter({"imageUrl"})
    public static void loadImage(ImageView imageView, String url) {
        RequestOptions mRequestOptions = new RequestOptions()
                .override(imageView.getWidth(), imageView.getHeight())
                .error(R.drawable.no_banner);
        Glide.with(imageView.getContext())
                .load(url)
                .apply(mRequestOptions)
                .into(imageView);
    }
}
